﻿namespace Collaboris.Saf.Actions.Wss.Entities
{
    using System;
    using System.Xml.Serialization;

    using SharePoint.Wss.Attributes;
    using SharePoint.Wss.Entities;

    using Utils;
    using System.Collections.Generic;
    using System.Data;

    [CollaborisClass(
        Title = "List Data Info",
        ReleaseStatus = ReleaseStatus.Beta,
        DisableDocumentation = false,
        ContactAuthorEmail = "Support@Collaboris.co.uk",
        Summary = "Defines the parameters to check in one or more files into a document library."
    )]
    [Serializable]
    public class ListDataInfo : WSSEntityBase
    {
        private string listName;
        
        private List<SerializableObjectDictionary<string>> rows;

        private string updateColumnKeys;

        private bool emptyListBeforeRun;

        private int listItemID;

        [CollaborisProperty(
           Summary = "Specifies the name of the list to update.",
           Title = "ListName",
           Example = @"Pages",
           Required = true,
           InputHint = InputHint.SingleText)]
        [XmlAttribute]
        public string ListName
        {
            get
            {
                return listName;
            }
            set
            {
                listName = value;
            }
        }

        [CollaborisProperty(
            Summary = "Specifies the column name " +
                     "and value of a list item",
            Title = "Rows",
             Example = @"<list element-type=""SafStringDictionary"">
				                <object type=""SafStringDictionary"">
					                <constructor-arg name=""dictionary"">
						                <dictionary>							
							                <entry key=""Title"" value=""Title1"" />
							                <entry key=""Description"" value=""My Desc"" />							                
						                </dictionary>
					                </constructor-arg>
				                </object>
			                </list>",
            Remarks = "",
            InputHint = InputHint.ObjectCollection,
            Required = true)]
        [XmlElement]
        public List<SerializableObjectDictionary<string>> Rows
        {
            get
            {
                return rows;
            }
            set
            {
                rows = value;
            }
        }

        [CollaborisProperty(
           Summary = "Specifies the column to query when deciding to insert or update the list data.",
           Title = "UpdateColumnKey",
           Example = @"Title",
           Required = true,
           InputHint = InputHint.SingleText)]
        [XmlAttribute]
        public string UpdateColumnKey
        {
            get
            {
                return this.updateColumnKeys;
            }
            set
            {
                this.updateColumnKeys = value;
            }
        }

        [CollaborisProperty(
           Summary = "Specify true to delete all of the data in the list prior to adding new.",
           Title = "Empty List Before Run",
           Example = @"true",
           Required = true,
           InputHint = InputHint.SingleText)]
        [XmlAttribute]
        public bool EmptyListBeforeRun
        {
            get
            {
                return this.emptyListBeforeRun;
            }
            set
            {
                this.emptyListBeforeRun = value;
            }
        }

        [CollaborisProperty(
           Summary = "Specifies the Id of the list Item to lookup.",
           Title = "List Item ID",
           Example = @"",
           Required = true,
           InputHint = InputHint.SingleText)]
        [XmlAttribute]
        public int ListItemID
        {
            get
            {
                return listItemID;
            }
            set
            {
                listItemID = value;
            }
        }


        private DataSet listDataSet;

        [CollaborisProperty(
           Summary = "Specifies a dataset containing the data to insert / update into the list.",
           Title = "List Data Set",
           Example = @"",
           Remarks = @"This needs to be passed in from another action that can supply the data." + 
                     @" Please look at <a href=""Collaboris.Saf.Actions.DataSet.GetDataSetFromCSV.html"">Get DataSet From CSV</a>"  + 
                     @" for an example on how to get a data set from a CSV file.",
           Required = true,
           InputHint = InputHint.DataSet)]
        [XmlAttribute]
        public DataSet ListDataSet
        {
            get
            {
                return listDataSet;
            }
            set
            {
                listDataSet = value;
            }
        }

    }
}
